﻿using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace SLS.ExClassLib.MultiThreading.Extensions
{
    public static class ArrayExtensions
    {
        public static bool DeepEquals(this IList source, IList target)
        {
            if (source == null || target == null)
                return false;

            if (source.Count != target.Count)
                return false;

            for (int i = 0; i < source.Count; i++)
            {
                if (!source[i].Equals(target[i]))
                    return false;
            }

            return true;
        }

        public static string ArrayToString<T>(this IEnumerable<T> array)
        {
            var result = new StringBuilder();

            foreach (T element in array)
            {
                if (result.Length > 0)
                    result.Append(", ");

                result.Append(element);
            }

            result.Insert(0, "{");
            result.Append("}");
            return result.ToString();
        }
    }
}